package cn.hx.controller.front.user;

import cn.hx.entity.UserInfo;
import cn.hx.service.UserInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("user")
public class ModifyController {
    @Resource
    private UserInfoService userInfoService;

    @GetMapping("modify")
    public String modify() {
        return "user/modify";
    }

    @PostMapping("modify/update")
    public String update(UserInfo userInfo, HttpSession httpSession) {

        userInfoService.update(userInfo);
        UserInfo userInfo1 = userInfoService.queryById(userInfo.getId());
        httpSession.setAttribute("userInfo",userInfo1);
        return "index";
    }
}